<?php

class ResultCode
{
//     const successCreate = 11;
//     const successRead = 21;
//     const successUpdate = 31;
//     const successDelete = 41;
// 
// //    append for parameter specific errors
//     const failCreate = 12;
//     const failRead = 22;
//     const failUpdate = 32;
//     const failDelete = 42;
// 
//     const authFailCreate = 13;
//     const authFailRead = 23;
//     const authFailUpdate = 33;
//     const authFailDelete = 43;
// 
//     const integFailCreate = 14;
//     const integFailRead = 24;
//     const integFailUpdate = 34;
//     const integFailDelete = 44;
// 
//     const sysError = 5;
	
	public static function successCreate(){
		return array('code' => 11, 'msg' => 'Success: Created new item.', 'success' => TRUE);
	}
	public static function successRead(){
		return array('code' => 21, 'msg' => 'Success: Read new item.', 'success' => TRUE);
	}
	public static function successUpdate(){
		return array('code' => 31, 'msg' => 'Success: Updated new item.', 'success' => TRUE);
	}
	public static function successDelete(){
		return array('code' => 41, 'msg' => 'Success: Deleted new item.', 'success' => TRUE);
	}
	public static function failCreate(){
		return array('code' => 12, 'msg' => 'Fail: Created new item.', 'success' => FALSE);
	}
	public static function failRead(){
		return array('code' => 22, 'msg' => 'Fail: Read new item.', 'success' => FALSE);
	}
	public static function failUpdate(){
		return array('code' => 32, 'msg' => 'Fail: Update new item.', 'success' => FALSE);
	}
	public static function failDelete(){
		return array('code' => 42, 'msg' => 'Fail: Delete new item.', 'success' => FALSE);
	}
	public static function authFailCreate(){
		return array('code' => 13, 'msg' => 'Authentication Fail: Create new item.', 'success' => FALSE);
	}
	public static function authFailRead(){
		return array('code' => 23, 'msg' => 'Authentication Fail: Read new item.', 'success' => FALSE);
	}
	public static function authFailUpdate(){
		return array('code' => 33, 'msg' => 'Authentication Fail: Update new item.', 'success' => FALSE);
	}
	public static function authFailDelete(){
		return array('code' => 43, 'msg' => 'Authentication Fail: Delete new item.', 'success' => FALSE);
	}
	public static function integFailCreate(){
		return array('code' => 14, 'msg' => "Integrity Datahash doesn't match: Create new item.", 'success' => FALSE);
	}
	public static function integFailRead(){
		return array('code' => 24, 'msg' => "Integrity Datahash doesn't match: Read new item.", 'success' => FALSE);
	}
	public static function integFailUpdate(){
		return array('code' => 34, 'msg' => "Integrity Datahash doesn't match: Update new item.", 'success' => FALSE);
	}
	public static function integFailDelete(){
		return array('code' => 44, 'msg' => "Integrity Datahash doesn't match: Delete new item.", 'success' => FALSE);
	}
	
	public static function parameterCodeHelper($resultarray, $param){
		$outcome = $resultarray;
		if (($param % 1) == 0) {
			$outcome['code'] = ($param * 100) + $outcome['code'];
		}
		return $outcome
	}
	
}